package com.mapaower.project.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.annotation.Id;
import jakarta.persistence.*;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 项目报名实体类
 * 表示开发人员报名项目的信息
 */
@Entity
@Table(name = "project_application")
public class ProjectApplication {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // 项目ID
    @Column(name = "project_id", nullable = false)
    private Long projectId;

    // 开发人员ID
    @Column(name = "developer_id", nullable = false)
    private Long developerId;

    // 开发技术栈（JSON格式存储）
    @Column(columnDefinition = "TEXT")
    private String technologies;

    // 开发周期（天）
    @Column(name = "development_cycle")
    private Integer developmentCycle;

    // 报价
    private BigDecimal price;

    // 报名状态：PENDING(待审核), APPROVED(已通过), REJECTED(已拒绝), WITHDRAWN(已撤回)
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private ApplicationStatus status;

    // 申请说明
    @Column(columnDefinition = "TEXT")
    private String applicationNote;

    // 创建时间
    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    // 更新时间
    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    // 报名状态枚举
    public enum ApplicationStatus {
        PENDING, APPROVED, REJECTED, WITHDRAWN
    }

    // Getter and Setter methods
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public Long getDeveloperId() {
        return developerId;
    }

    public void setDeveloperId(Long developerId) {
        this.developerId = developerId;
    }

    public String getTechnologies() {
        return technologies;
    }

    public void setTechnologies(String technologies) {
        this.technologies = technologies;
    }

    public Integer getDevelopmentCycle() {
        return developmentCycle;
    }

    public void setDevelopmentCycle(Integer developmentCycle) {
        this.developmentCycle = developmentCycle;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public ApplicationStatus getStatus() {
        return status;
    }

    public void setStatus(ApplicationStatus status) {
        this.status = status;
    }

    public String getApplicationNote() {
        return applicationNote;
    }

    public void setApplicationNote(String applicationNote) {
        this.applicationNote = applicationNote;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}